﻿using System;
using System.Reflection;
using bpms.Dao;
using bpms.Models;

namespace bpms.Service
{
    /// <summary>
    /// 客户业务层
    /// </summary>
    public class CustomerService
    {
        private readonly CustomerDao customerDao;
        public CustomerService(CustomerDao dao)
        {
            customerDao = dao;
        }
        /// <summary>
        /// 查询所有客户
        /// </summary>
        /// <returns></returns>
        public List<Customer> GetAll(string searchKey)
        {
           return customerDao.GetAll(searchKey);
        }

        /// <summary>
        /// 根据Id查询客户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Customer GetById(int id)
        {
            return customerDao.GetById(id);
        }

        /// <summary>
        /// 添加客户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Customer model)
        {
            return customerDao.Add(model);
        }

        public int Update(Customer Customer)
        {
            return customerDao.Update(Customer);
        }

        /// <summary>
        /// 根据登录名查询客户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public Customer GetByLoginName(string loginName)
        {
            return customerDao.GetByLoginName(loginName);
        }

        /// <summary>
        /// 根据登录名和密码查询客户
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public Customer GetByLoginNameAndPwd(string loginName, string password)
        {
            return customerDao.GetByLoginNameAndPwd(loginName,password);
        }

        public int Delete(int id)
        {
            return customerDao.Delete(id);
        }
    }
}
